const WebSocket = require('ws');

const wss = new WebSocket.Server({ port: 8080 });
console.log('WebSocket服务器启动在端口 8080');

const mockData = {
    "code": 200,
    "data": {
        "list": [
            {
                "tid": "track1",
                "pts": [
                    {"lat": 30.2472879540001, "lng": 120.111792521, "ts": 1756010948, "spd": 0, "alt": 0},
                    {"lat": 30.249504, "lng": 120.117795, "ts": 1756011017, "spd": 40, "alt": 100}
                ],
                "startTime": 1756010958,
                "endTime": 1756011017
            }
        ]
    }
};

wss.on('connection', (ws) => {
    console.log('客户端已连接');
    ws.send(JSON.stringify(mockData));
    
    ws.on('close', () => {
        console.log('客户端断开连接');
    });
});
